<?php
class sis_setup_allow_transaksi_model extends MY_Model {
	var $model = 'sis_setup_allow_transaksi';
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	KODE_JENIS_TRANSAKSI, NAMA_JENIS_TRANSAKSI, TREE_LEVEL, KODE_JENIS_TRANSAKSI_INDUK ";
		
			$arr_data = $this->GetAllJenisAnggota();
			for($i=0, $max_i=count($arr_data); $i<$max_i; $i++){
				$row = $arr_data[$i];
				$key	= strtolower($row['kd_jenis_anggota']);
				$ls_sql	.=	",(SELECT x.PERSEN_LIMIT FROM SIS_SETUP_LIMIT_KREDIT x WHERE x.KODE_JENIS_TRANSAKSI = a.KODE_JENIS_TRANSAKSI AND LOWER(x.KD_JENIS_ANGGOTA)='".$key."') persen_limit_".$key." ";
			}
			
		$ls_sql	.= "FROM	VW_SIS_JENIS_TRANSAKSI a";
					
		return json_encode( $this->paging($ls_sql) );
	}
	
	function GetAllJenisAnggota(){
		$result	= $this->db->query("SELECT kd_jenis_anggota, nama_jenis_anggota FROM sis_setup_jenis_anggota ORDER BY kd_jenis_anggota");
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}
	
	/*function Add($arr_data){
		$this->db->insert('sw_jenis_umk', $arr_data);
	}
	
	function Update($arr_data, $arr_trans){
		$this->db->update('sw_jenis_umk', $arr_data, $arr_trans);
	}
	
	function GetSingle($as_code){
		$result = $this->db->get_where('sw_jenis_umk', array('code' => $as_code));
		if($result->num_rows() == 1){
			return $result->row_array();
		}else{
			return NULL;
		}
	}
	
	function GetSingleView($as_code)
	{
		$result = $this->db->get_where('sw_jenis_umk', array('code' => $as_code));
		if($result->num_rows() == 1){
			return $result->row_array();
		}else{
			return NULL;
		}
	}

	function DeleteSingle($as_code)
	{
		try {
			$this->db->delete('sw_jenis_umk', array('code' => $as_code));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}*/
}
?>